package com.by;

import com.by.pojo.User;
import com.by.tools.SimpleORM;

import java.util.List;

/**
 * Hello world!
 *
 */
public class Main {
    public static void main(String[] args) {
        try {
            // 初始化 ORM 工具
            SimpleORM orm = new SimpleORM("jdbc:mysql://192.168.41.41:3306/handle_framwork", "root", "1357");
            // 创建并插入用户
            User user = new User();
            user.setId(4);
            user.setName("Alice");
            user.setAge(25);
            orm.insert(user);
            // 查询所有用户
            List<User> users = orm.queryAll(User.class);
            for (User u : users) {
                System.out.println("ID: " + u.getId() + ", Name: " + u.getName() + ", Age: " + u.getAge());
            }
            // 关闭连接
            orm.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}